#!/usr/bin/python

import time, sys
from math import sqrt, ceil, floor

""" 
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91  99.

Find the largest palindrome made from the product of two 3-digit numbers.
"""

def ispalindrome(x):
    x = str(x)
    if x == x[::-1]:
        return True
    return False

def main():
    start = time.time()
    
    print ispalindrome(9009)
    print ispalindrome(992)
    
    max = 0
    for x in range(999):
        for y in range(999):
            product = x * y
            if ispalindrome(product):
                if product > max:
                    max = product
                    ans = (x, y)

    print max, ans
    print '{0:.2f} s'.format(time.time() - start)        

# solution 1: 906609 in 0.89 s

if __name__ == '__main__':
  main()
